package com.longteng.lession.http;


import com.google.common.collect.Maps;
import com.google.common.io.Resources;
import spark.ModelAndView;
import spark.Spark;
import spark.template.freemarker.FreeMarkerEngine;

import java.util.Map;

import static spark.Spark.*;
/**
 * Created by celes on 2015/12/12
 *
 * sinatra
 */
public class MyWeb {

    public static void main(String[] args) {
        Spark.get("/",(request1, response1) -> "hello");
        staticFileLocation(Resources.getResource("public").getFile());
        get("/", ((request, response) -> "hello,world"));
        get("/health", ((request, response) -> "ok"));
        get("/index", (request, response) -> {
            Map<String, String> attributes = Maps.newHashMap();
            attributes.put("name", "tester");
            return new ModelAndView(attributes, "index.ftl");
        }, new FreeMarkerEngine());
    }

}
